<style scoped>
</style>
<template>
  <van-field v-bind="$attrs"
             :readonly="is_info"
             :placeholder="placeholder"
             type="textarea"
             :autosize="{maxHeight:400, minHeight:60}"
             :show-word-limit="!is_info"
             :maxlength="maxlength"
             :name="is_info?'':name"
             :model-value="modelValue"
             label-align="top"
             @update:model-value="$emit('update:modelValue', $event)"
             @change="$emit('change', $event)" >
  </van-field>
</template>

<script>
export default {
  name: "text_more",
  props: {
    name: String,
    modelValue: [String,Number],
    config: [String,Object],
    placeholder: String,
    is_info: Boolean,
  },
  emits: ['update:modelValue','change'],
  data(){
    return {
      maxlength: undefined,
    }
  },
  methods: {
    display(){
      let config = this.config;
      if (!config) return;
      if (typeof config === 'string'){
        try {
          config = JSON.parse(config);
        } catch (e) {}
      }
      if (typeof config !== 'object') config = {}
      this.maxlength = config.maxlength;
    },
  },
  watch: {
    config(v){
      this.display();
    },
  },
  computed: {},
  mounted() {
    this.display()
  }
}
</script>